<?php if( ! $this->sg->is_subscribed($subject['id_subject']) && $subject['password'] != ''): ?>  
  <a name="subscribe-anchor"></a>
  <div id="subscribe-password">
    <span class="key-icon">Este curso requiere una contrase&ntilde;a para suscribirse: </span>
    <input type="password" name="subject_password" id="subject_password" />
    <input type="button" id="subject_password_submit" value="Suscribirme" onclick="submit_password(<?php echo $subject['id_subject'] ?>)" />
  </div>
<?php endif; ?>

<div class="subject-info">
  <h2>Noticias</h2>
  <div class="subject-news">
    
    <?php if( ! $this->sg->can_view_subject($subject) ) :?>
    
    Este curso es privado y debes estar suscrito a &eacute;l para ver su contenido.
    
    <?php else: ?>
    
    <?php foreach($news as $newsitem): ?>
      <h3><?php echo $newsitem['title'] ?></h3>
      <span class="meta">
        <span class="user-icon"><?php echo $newsitem['name']?></span>
        <span class="period-icon">Publicada el <abbr class="expand" title="a las <?php echo date('H:i', strtotime($newsitem['created']))?>"><?php echo date('d/m/Y', strtotime($newsitem['created']))?></abbr>.</span>
      </span>
      <p><?php echo nl2br($newsitem['body']) ?></p>
      <div class="news-separator"></div>
    <?php endforeach; ?>
    <?php if(count($news) == 0) :?>
      <small>No hay noticias.</small>
    <?php endif; ?>
    
    <?php endif; // Privacidad del curso ?>
  </div>
</div>

<div class="right-bar">
  <div class="subject-meta">
    <h1><?php echo $subject['name']; ?></h1>
    <p>
      <span class="faculty-icon"><abbr title="<?php echo $subject['campus_name']; ?>"><?php echo $subject['faculty_name']; ?></abbr></span>
    </p>
    <p>
      <span class="period-icon">Per&iacute;odo <?php echo $subject['period']; ?></span>
    </p>
  
    <?php if( $this->sg->can_view_subject($subject) ) :?>
    
    <p>
      <span class="files-icon">Archivos</span>
      <ul class="folders">
      <?php foreach($folders as $folder): ?>
        <li>
          <?php // echo anchor('viewfolder/' . $folder['id_folder'], $folder['name']) ?>
          <a href="javascript:;" onclick="browse_folder(<?php echo $folder['id_folder'] ?>, '#browse-folder-<?php echo $folder['id_folder'] ?>')"><?php echo $folder['name'] ?></a>
        
          <div id="browse-folder-<?php echo $folder['id_folder'] ?>" class="file-list-div"></div>
        </li>
      <?php endforeach; ?>
      <?php if(count($folders) == 0): ?><li>No hay carpetas</li></a><?php endif; ?>
      </ul>
    </p>
    <p></p>
    <p>
      <span class="contact-icon">Contacto</span>
      <ul class="contact">
        <?php foreach($users as $user): ?>
          <li class="<?php echo ($user['relationship_type'] == TEACHER)?('teacher'):('ta') ?>">
            <?php echo safe_mailto($user['email'], $user['name']); ?> [<?php echo ($user['relationship_type'] == TEACHER)?('Profesor'):('Ayudante') ?>]
          </li>
        <?php endforeach; ?>
        <?php if(count($users) == 0): ?><li class="none">No hay informaci&oacute;n de contacto</li></a><?php endif; ?>
      </ul>
    </p>
  
    <?php endif; // Privacidad del curso ?>
  </div>

  <div class="subject-meta second-meta">
    <h1>Opciones</h1>
    <?php /* Esta parte es exclusiva para suscritos, da lo mismo si es admin */ ?>
    <?php if($this->sg->is_subscribed($subject['id_subject'])): ?>
    
    <?php /* Un profe / ayudante no deberia poder eliminar su suscripcion */ ?>
    <?php if( ! $this->sg->is_teacher($subject['id_subject']) && ! $this->sg->is_ta($subject['id_subject'])) : ?>
    <p><span class="unsubscribe-icon"><a href="javascript:;" onclick="unsubscribe(<?php echo $subject['id_subject'] ?>)">Eliminar suscripci&oacute;n</a></span></p>
    <?php endif; ?>
    
    <p><span class="notifications-icon">Notificaciones</span></p>
    <ul class="notifications-list">
      <li><input type="checkbox" id="receive-news-notifications" name="news-<?php echo $subject['id_subject'] ?>" <?php echo ($this->sg->news_notifications($subject['id_subject']))?('checked="checked"'):(''); ?> /> <label for="receive-news-notifications">Notificarme de noticias nuevas</label></li>
      <li><input type="checkbox" id="receive-files-notifications" name="files-<?php echo $subject['id_subject'] ?>" <?php echo ($this->sg->files_notifications($subject['id_subject']))?('checked="checked"'):(''); ?> /> <label for="receive-files-notifications">Notificarme de archivos nuevos</label></li>
    </ul>
    
    <?php else: ?>
    <p><span class="subscribe-icon"><a href="javascript:;" onclick="subscribe<?php echo ($subject['password'] != '')?('_password'):('') ?>(<?php echo $subject['id_subject'] ?>)">Suscribirme a este curso</a></span></p>
    
    <?php endif; // Si esta suscrito ?>
    
    <?php if($this->sg->can_post($subject['id_subject'])): ?>
      <p><span class="post-icon"><?php echo anchor('news/post/' . $subject['id_subject'], 'Nueva noticia'); ?></span></p>
    <?php endif; ?>
    
    <?php if($this->sg->can_create_folder($subject['id_subject'])): ?>
      <p><span class="folder-add-icon"><?php echo anchor('folders/create/' . $subject['id_subject'], 'Nueva carpeta'); ?></span></p>
    <?php endif; ?>
    
    <?php if($this->sg->can_upload($subject['id_subject'])): ?>
      <p><span class="upload-icon"><?php echo anchor('folders/create/' . $subject['id_subject'], 'Subir archivo'); ?></span></p>
    <?php endif; ?>
    
  </div>
</div>

<div class="clear"></div>